import { Global, Module } from "@nestjs/common";
import { ClientsModule, Transport } from '@nestjs/microservices'
import { RedisCacheService } from './redis.service'
import Redis from 'ioredis';

@Global()
@Module({
  imports: [
    // 连接Redis
    ClientsModule.register([{
      name: 'MATH_SERVICE',
      transport: Transport.REDIS,
      options: {
        host: 'localhost',
        port: 6379
      }
    }])
  ],
  controllers: [],
  providers: [RedisCacheService, Redis],
  exports: [RedisCacheService]
})
export class RedisModule { }